<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListAnnounceTitle}"></h:outputText>
        </ui:define>
        <center>
            <ui:define name="body">
                <div style=" height: auto; float:none ; width: 1040px;">
                    <div style=" height: auto; float:left ; width: 200px;">
                        <h:form>
                            <h:outputLabel value="Address: " for="searchAddress" />
                            <h:inputText id="searchAddress" value="#{announceController.searchAddress}" title="Address" />
                            <br />
                            <h:outputLabel value="Postcode: " for="searchPostcode" />
                            <h:inputText id="searchPostcode" value="#{announceController.searchPostcode}" title="Postcode" />
                            <br />
                            <h:outputLabel value="Number Bathroom(min): " for="searchMinNumberBathroom" />
                            <h:inputText id="searchMinNumberBathroom" value="#{announceController.searchMinNumberBathroom}" title="Number Bathroom(min)" />
                            <br />
                            <h:outputLabel value="Number Bathroom(max): " for="searchMaxNumberBathroom" />
                            <h:inputText id="searchMaxNumberBathroom" value="#{announceController.searchMaxNumberBathroom}" title="Number Bathroom(max)" />
                            <br />
                            <h:outputLabel value="Number Bedroom(min): " for="searchMinNumberBedroom" />
                            <h:inputText id="searchMinNumberBedroom" value="#{announceController.searchMinNumberBedroom}" title="Number Bedroom(min)" />
                            <br />
                            <h:outputLabel value="Number Bedroom(max): " for="searchMaxNumberBedroom" />
                            <h:inputText id="searchMaxNumberBedroom" value="#{announceController.searchMaxNumberBedroom}" title="Number Bedroom(max)" />

                            <br />

                            <h:outputLabel value="Furnished: " for="searchFurnished" />
                            <h:selectOneMenu id="searchFurnished" value="#{announceController.searchFurnished}" title="Furnished">
                                <f:selectItems value="#{announceController.populateFurnitureDropDownList}"/>
                            </h:selectOneMenu>
                            <br />
                            <h:outputLabel value="Type: " for="searchType" />
                            <h:inputText id="searchType" value="#{announceController.searchType}" title="Type" />
                            <br />
                            <h:outputLabel value="Garden: " for="searchGarden" />
                            <h:selectOneMenu id="searchGarden" value="#{announceController.searchGarden}" title="Garden">
                                <f:selectItems value="#{announceController.populateGardenDropDownList}"/>
                            </h:selectOneMenu>
                            <br />

                            <h:commandButton action="#{announceController.prepareList}" value="Search"/>
                            <br />
                        </h:form>
                    </div>
                    <div style=" height: auto; width: 824px; border-left: 10px">
                        <h:form styleClass="jsfcrud_list_form">
                            <h:panelGroup id="messagePanel" layout="block">
                                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                            </h:panelGroup>
                            <h:outputText escape="false" value="#{bundle.ListAnnounceEmpty}" rendered="#{announceController.items.rowCount == 0}"/>
                            <h:panelGroup rendered="#{announceController.items.rowCount > 0}">
                                <h:outputText value="#{announceController.pagination.pageFirstItem + 1}..#{announceController.pagination.pageLastItem + 1}/#{announceController.pagination.itemsCount}"/>&nbsp;
                                <h:commandLink action="#{announceController.previous}" value="#{bundle.Previous} #{announceController.pagination.pageSize}" rendered="#{announceController.pagination.hasPreviousPage}"/>&nbsp;
                                <h:commandLink action="#{announceController.next}" value="#{bundle.Next} #{announceController.pagination.pageSize}" rendered="#{announceController.pagination.hasNextPage}"/>&nbsp;



                                <h:dataTable value="#{announceController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                                    <h:column>     
                                        <div style="background-color: #DDDDDD; height: auto; width: 600px; float: left;" onmouseover="this.style.backgroundColor='#EEEEEE'" onmouseout="this.style.backgroundColor='#DDDDDD'" >
                                            <div style="background-color: transparent; height: inherit; width: 600px; float: left; margin: 3px 3px 3px 3px;">
                                                <div style="background-color: transparent; height: 70px; width: 100px; float: left; margin: 3px 3px 3px 3px;">
                                                    <!--                                            <h:outputText value="{item.idProperty.imageCollection[0].path}"/>-->
                                                    <h:graphicImage id="thumb" url="../#{item.idProperty.imageCollection[0].path}" alt="thumb" height="70" width="100px" />
                                                </div>

                                                <div style="background-color: transparent; height: auto; width: 150px; float: left; margin: 3px 3px 3px 3px;">
                                                    address:
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.address}"/>
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.address2}"/>
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.postcode}"/>
                                                </div>
                                                <div style="background-color:transparent; float: left; height: 50px; width: auto; margin:3px 8px 1px 8px;">
                                                    type:
                                                    <br />
                                                    <h:outputText value="#{item.type}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin:3px 8px 1px 8px;">
                                                    status:
                                                    <br />
                                                    <h:outputText value="#{item.status}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin: 3px 8px 1px 8px;">
                                                    price:
                                                    <br />
                                                    <h:outputText value="#{item.price}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin:3px 8px 1px 8px;">
                                                    bedroom:
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.numberBedroom}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin:3px 8px 1px 8px;">
                                                    bathroom:
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.numberBathroom}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin:3px 8px 1px 8px;">
                                                    garden:
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.garden}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin:3px 8px 1px 8px;">
                                                    furniture:
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.furniture}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin:3px 5px 1px 5px;">
                                                    size m²:
                                                    <br />
                                                    <h:outputText value="#{item.idProperty.sizeSquareMetre}"/>
                                                </div>
                                                <div style="background-color: transparent; float: left; height: 50px; width: auto; margin:3px 5px 1px 5px;">
                                                    status:
                                                    <br />
                                                    status
                                                </div>
                                                <br />
                                                <div style=" background-color:transparent; float:left; height:auto; width:500; margin:0px 5px 1px 5px;">
                                                    Description:
                                                    <h:outputText value="#{item.description}" /><br /> <br />
                                                    <h:outputText value="Owner username: " style="color: #e33b06" />
                                                    <h:outputText value="#{item.idProperty.ownerUsername.username}" style="color: blue"/>&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <h:outputText value="Logged username: " style="color: #e33b06" />
                                                    <h:outputText value="#{sessionScope.username}"  style="color: blue"/>&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <h:outputText value="role owner? " style="color: #e33b06" />
                                                    <h:outputText value="#{sessionScope.owner}" style="color: blue"/><br />
                                                    <h:outputText value="role agent? " style="color: #e33b06" />
                                                    <h:outputText value="#{sessionScope.agent}" style="color: blue"/>&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <h:outputText value="role user? " style="color: #e33b06" />
                                                    <h:outputText value="#{sessionScope.user}" style="color: blue"/><br />
                                                </div>

                                            </div>
                                            <div style=" background-color:transparent; float:right; height:inherit; width:50; margin:  0px 5px 5px 5px;">
                                                <h:commandLink action="#{announceController.prepareView}" value="#{bundle.ListPropertyViewLink}"/>
                                            </div>

                                            <div style=" background-color:transparent; float:right; height:inherit; width:50; margin:  0px 5px 5px 5px;">

                                                <h:commandLink action="#{announceController.prepareEdit}" value="#{bundle.ListPropertyEditLink}" rendered="#{(sessionScope.agent==true) or (sessionScope.owner==true and item.idProperty.ownerUsername.username == sessionScope.username)}" />&nbsp;&nbsp;
                                                <h:commandLink action="#{announceController.destroy}" value="#{bundle.ListPropertyDestroyLink}" rendered="#{(sessionScope.agent==true) or (sessionScope.owner==true and item.idProperty.ownerUsername.username == sessionScope.username)}"/>
                                            </div>

                                        </div>

                                    </h:column>

                                </h:dataTable>


                            </h:panelGroup>
                            <br />
                            <h:commandLink action="#{announceController.prepareCreate}" value="#{bundle.ListAnnounceCreateLink}" rendered="#{(sessionScope.agent==true) or (sessionScope.owner==true)}"/>

                        </h:form>
                    </div>
                </div>
            </ui:define>
        </center>
    </ui:composition>

</html>
